from PyQt5.QtWidgets import QTextEdit, QLabel, QMessageBox

class ResultDisplay(QTextEdit):
    def __init__(self):
        super().__init__()
        self.setup_ui()
        self.status_label = QLabel("准备就绪")
        
    def setup_ui(self):
        self.setReadOnly(True)
    
    def show_warning(self, message):
        """显示警告消息"""
        QMessageBox.warning(self, "警告", message)
    
    def show_result(self, data):
        """显示结果数据"""
        formatted = self._format_data(data)
        self.setPlainText(formatted)
        self.status_label.setText("请求完成")
    
    def show_error(self, error):
        """显示错误信息"""
        self.setPlainText(f"错误: {str(error)}")
        self.status_label.setText("请求失败")
    
    def clear(self):
        """清空显示"""
        super().clear()
        self.status_label.setText("准备就绪")
    
    def _format_data(self, data):
        """格式化数据为字符串"""
        # ... 格式化逻辑 ...

    def show_success(self, message):
        """显示成功消息"""
        self.setText(message)  # 假设有 setText 方法
        self.setStyleSheet("color: green;")  # 设置为绿色表示成功